﻿namespace LeadMaster.Helpers
{
  using System.Net;
  using System.Net.Mail;
  using System.Collections.Generic;

  public class OracMailMessage
  {
    public string EmailTo { get; set; }
    public string EmailSubject { get; set; }
    public string EmailBody { get; set; }
    public string cc { get; set; }
    private bool html;

    public OracMailMessage(bool Html=false)
    {
      this.html = Html;
    }

    public void SendEmail()
    {
      MailMessage eMail = new MailMessage();
      eMail.From = new MailAddress("orac@dunsmorecrm.co.uk");
      eMail.To.Add(EmailTo);
      if (cc!=null)
      {
        eMail.CC.Add(cc);  
      }
      eMail.Subject = EmailSubject;
      eMail.Body = EmailBody;
      eMail.IsBodyHtml = html;

      NetworkCredential mailAuthentication = new NetworkCredential("orac@dunsmorecrm.co.uk", "20hamlet");
      SmtpClient SMTP = new SmtpClient("mail.dunsmorecrm.co.uk", 25);
      SMTP.UseDefaultCredentials = false;
      SMTP.Credentials = mailAuthentication;
      bool notSent = false;
      try
      {
        SMTP.Send(eMail); 
      }
      catch (System.Exception)
      {
        notSent = true;
      }
      
    }
  }
}